#ifndef WOKERQOBJECT_H
#define WOKERQOBJECT_H

#include <QObject>
#include <QDebug>
#include <QThread>
#include <QTimer>

class WorkerThread : public QThread
{
    Q_OBJECT
public:
    void run() override
    {
        QThread::currentThread()->setObjectName("WorkerThread");
        QObject obj;
        qDebug() << obj.thread();


        QTimer timer;
        connect(&timer, &QTimer::timeout, [](){
            qDebug() << "Timer triggered in worker thread:" << QThread::currentThread();
        });
        qDebug() << timer.thread();
        timer.start(1000);
        exec();
    }
};


class Worker : public QObject
{
    Q_OBJECT
public slots:
    void Start()
    {
        QThread::currentThread()->setObjectName("Woker");
        QTimer* timer = new QTimer(this);
        connect(timer,&QTimer::timeout,this,[=](){
            qDebug() <<  "Timer in worker:" << QThread::currentThread();
        });
        timer->start(1000);
    }
};

#endif // WOKERQOBJECT_H
